package com.cloud.api.domain.tsp;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.cloud.core.entity.base.BaseEntity ;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Pattern;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author haohaibo
 * @since 2023-12-20
 */
@Getter
@Setter
@Accessors(chain = true)
@TableName("t_vehicle_production")
@Schema(name = "VehicleProduction", description = "生产车辆管理")
public class VehicleProduction extends BaseEntity implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    private String id;

    @TableField("vin")
    @NotEmpty(message = "{validation.Information.vin}")
    @Size(max = 17,min = 17,message = "{validation.Information.vinSize}")
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z\\d]{17}$", message = "{validation.Information.vinSize}")
    private String vin;

    @Schema(description = "品牌")
    @TableField("model_brand")
    @NotEmpty(message = "{validation.production.brand}")
    private String modelBrand;

    @Schema(description = "车系")
    @TableField("model_series")
    @NotEmpty(message = "{validation.production.series}")
    private String modelSeries;

    @Schema(description = "车型")
    @TableField("model_type")
    @NotEmpty(message = "{validation.production.type}")
    private String modelType;

    @Schema(description = "生产日期")
    @TableField("production_date")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @NotNull(message = "{validation.production.productionDate}")
    private Date productionDate;

    @Schema(description = "生产日期格式化数据")
    @TableField(exist = false)
    private String productionDateStr;

    @Schema(description = "版本名称",hidden = true)
    @TableField(exist = false)
    private String modelName;

    @Schema(description = "组织机构")
    @TableField("dept")
    @NotEmpty(message = "{validation.production.dept}")
    private String dept;

    @Schema(description = "电机号")
    @TableField("motor_number")
    @NotEmpty(message = "{validation.production.motorNumber}")
    @Size(max = 30,message = "{validation.common.maxSize}")
    @Pattern(regexp = "^[A-Za-z0-9]{1,30}$", message = "{validation.production.motorNumberGrex}")
    private String motorNumber;

    @Schema(description = "电池包编码")
    @TableField("battery_pack_code")
    private String batteryPackCode;

    @Schema(description = "SIM卡号")
    @TableField("sim_number")
    @NotEmpty(message = "{validation.Information.sim}")
    @Size(max = 20,min = 8,message = "{validation.common.size}")
    private String simNumber;

    @Schema(description = "TBOX设备号")
    @TableField("tbox_number")
    @NotEmpty(message = "{validation.Information.tbox}")
//    @Size(max = 17,min = 17,message = "{validation.Information.vinSize}")
    @Pattern(regexp = "^[A-Za-z0-9]{1,17}$", message = "{validation.production.tboxNumberRegex}")
    private String tboxNumber;

    @Schema(description = "ICCID")
    @TableField("iccid")
    @NotEmpty(message = "{validation.Information.iccid}")
    @Size(max = 30,message = "{validation.common.maxSize}")
    @Pattern(regexp = "^(?!^[a-zA-Z]+$)[a-zA-Z0-9]{1,30}$", message = "{validation.production.iccidRegex}")
    private String iccid;

    @Schema(description = "车辆类型：油车电车")
    @NotEmpty(message = "{validation.production.vehicleType}")
    @TableField("vehicle_type")
    private String vehicleType;

    @Schema(description = "电控编码")
    @TableField("electric_code")
    @Size(max = 30,min = 1,message = "{validation.common.electricCodeSize}")
    @Pattern(regexp = "^[A-Za-z0-9]{1,30}$", message = "{validation.production.electricCodeRegex}")
    private String electricCode;

    @Schema(description = "设备编号")
    @Size(max = 17,min = 17, message = "{validation.production.did}")
    @Pattern(regexp = "^(?=.*[A-Za-z])(?=.*\\d)[A-Za-z0-9]{17}$", message = "{validation.production.didRegex}")
    @TableField("did")
    private String did;

    @Schema(description = "公告型号",hidden = true)
    @TableField(exist = false)
    private String noticeModel;

    @Schema(description = "生产数量",hidden = true)
    @TableField(exist = false)
    private Integer productionCount;
}